<hr/>
<div class="row-fluid">
    <div class="span12">
        <button class="btn btn-success" id="btn_save">保存</button>
        <#if member.memberId??>
            <a id="btn_order" href="${request.contextPath}/member/order/list?memberId=${member.memberId}" class="btn btn-info">历史订单</a>
            <a id="btn_point" href="${request.contextPath}/member/point/list?memberId=${member.memberId}" class="btn btn-info">会员积分</a>
        </#if>
        <a id="btn_back" href="${request.contextPath}/member/memberList" class="btn btn-info">返回列表</a>
        <div class="widget-box">
            <div class="widget-title"> <span class="icon"> <i class="icon-pencil"></i> </span>
                <h5>会员信息</h5>
            </div>
            <div class="widget-content nopadding">
                <form class="form-horizontal" method="post" action="${request.contextPath}/member/saveMemberInfo" name="member_form" id="member_form">
                    <input type="hidden" name="memberId" value="${member.memberId}" />
                    <div class="control-group">
                        <label class="control-label">会员编号：</label>
                        <div class="controls">
                            <input type="text" name="memberNo" value="${member.memberNo}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">会员姓名：</label>
                        <div class="controls">
                            <input type="text" name="memberName" value="${member.memberName}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">会员等级：</label>
                        <div class="controls">
                            <select name="memberLevelId">
                                <#list levelList as level>
                                    <option value="${level.memberLevelId}" <#if level.memberLevelId == member.level>selected</#if> >${level.levelName}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">性别：</label>
                        <div class="controls">
                            <select name="gender">
                                <option value="M">先生</option>
                                <option value="F">女士</option>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">生日：</label>
                        <div class="controls">
                            <input type="text" name="birthday" value="${member.birthday}"> (yyyy-mm-dd, 年-月-日)
                            <!--<span class="help-block blue span8">日/月/年</span>-->
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">电话号码：</label>
                        <div class="controls">
                            <input type="text" name="mobile" value="${member.mobile}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">邮箱：</label>
                        <div class="controls">
                            <input type="text" name="email" value="${member.email}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">QQ：</label>
                        <div class="controls">
                            <input type="text" name="qq" value="${member.qq}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">住址：</label>
                        <div class="controls">
                            <input type="text" name="address" value="${member.address}">
                        </div>
                    </div>
                    <!--<div class="control-group">-->
                        <!--<label class="control-label"></label>-->
                        <!--<div class="controls">-->
                            <!--<input type="submit" value="保存" class="btn btn-success">-->
                            <!--<input type="reset" value="重置" class="btn btn-danger" >-->
                        <!--</div>-->
                    <!--</div>-->
                </form>
            </div>
        </div>
    </div>
</div>
<script src="${request.contextPath}/js/jquery-1.12.2.min.js"></script>
<script src="${request.contextPath}/js/jquery.validate.js"></script>
<script src="${request.contextPath}/js/sweetalert.min.js"></script>
<script type="text/javascript">
    $(function(){

        $("#btn_save").click(function(){
            $("#member_form").submit();
        });

        $("#btn_back").click(function(){
            loadPage($(this).attr("href"));
            return false;
        });

        $("#btn_point").click(function(){
            loadPage($(this).attr("href"));
            return false;
        });

        $("#btn_order").click(function(){
            loadPage($(this).attr("href"));
            return false;
        });

        $("#member_form").validate({
            submitHandler: function(form){
                $.ajax({
                    url: $(form).attr("action"),
                    type: "post",
                    data: $(form).serialize(),
                    success: function(result){
                        swal({
                            title: "信息提示",
                            text: result.status == "success" ? "恭喜，操作已完成！" : "很遗憾，操作失败了！",
                            type: result.status,
                            animation: "slide-from-top"
                        }, function(){
                            if (result.status == "success"){
                                loadPage("${request.contextPath}/member/memberList");
                            }
                        });
                    }
                });
            },
            rules: {
                memberNo: {
                    "required": true
                },
                memberName: {
                    "required": true
                },
                mobile: {
                    "required": true
                }
            },
            errorClass: "help-inline",
            errorElement: "span",
            highlight:function(element, errorClass, validClass) {
                $(element).parents('.control-group').addClass('error');
            },
            unhighlight: function(element, errorClass, validClass) {
                $(element).parents('.control-group').removeClass('error');
                $(element).parents('.control-group').addClass('success');
            }

        });
    })
</script>